package cn.arts.assumejson.algo.algo4;

/**
 * @author by <a href="mailto:ligang941012@gmail.com">gang.Li</a>
 * @since 3/12/2025 10:05 PM
 */
public class SingletonList<E> implements List<E> {

    private int size = 0;

    private Node<E> first;

    private Node<E> last;


    public SingletonList() {
    }


    @Override
    public int size() {
        return size;
    }

    @Override
    public boolean isEmpty() {
        return size == 0;
    }

    @Override
    public boolean add(E e) {
        Node<E> current = new Node<>(null, e);
        if (first == null) {
            first = current;
        } else {
            last.next = current;
        }
        last = current;
        return true;
    }

    @Override
    public boolean remove(E e) {
        return false;
    }

    private static class Node<E> {
        private Node<E> next;
        private E current;

        public Node(Node<E> next, E current) {
            this.next = next;
            this.current = current;
        }
    }
}
